package love.yuanmengrobot.als.utilPublic;
/*
 *   @Studio:CHJY · 源梦科技
 *   @Author:CHJY创幻
 *   @Ide:IntelliJ IDEA
 *   @Creation time:2021/6/27 16:44
 */

import love.yuanmengrobot.als.business.javaBean.Alstrainplan;
import love.yuanmengrobot.als.business.javaBean.Alstrainplancourse;

public class SqlStringImportPlain {

    /**
     * 查找专业
     * @param
     * @return 返回查询sql
     */
    public static String selectMajor(){
        return "Select MAJOR_ID,MAJOR_NAME from Major";
    }
    /**
     * 查找培养方案
     * @param
     * @return 返回查询sql
     */
    public static String selectTrainPlan( String majorId){
        return  "select TRAINPLAN_ID,MAJOR_ID,GRADE,OPTIONAL_CREDIT,LIMITE_CREDIT,PROFESSIONAL_REQUIRED,GENERAL_REQUIRED,GENERAL_ELECTIVE,DISCIPLINE_BASIS,PRACTICE_LINK from alstrainplan where MAJOR_ID="+majorId;
    }
    /**
     * 查找培养方案的课程
     * @param
     * @return 返回查询sql
     */
    public static String selectTrainPlancourse( String trainplain){
        return "select TRAINPLANCOURSE_ID,TRAINPLAN_ID,COURSE_NAME,PLAN_COURSE_TERM,CREDIT,COURSE_TYPE,COURSE_HOURS,COURSE_LEVEL from alstrainplancourse  where TRAINPLAN_ID="+trainplain;
    }
    /**
     * 插入专业
     * @param
     * @return 返回查询sql
     */
    public static String insertMajor( String majorName){
        return "insert into major values(null,'"+majorName+"')";
    }

    /**
     * 专业改名
     * @param
     * @return 返回查询sql
     */
    public static String updateMajor( String majorID,String majorName){
        return "update major set major_name='"+majorName+"' where major_id="+majorID;
    }

    /**
     * 修改培养方案
     * @param
     * @return 返回查询sql
     */
    public static String updatePlain(Alstrainplan alstrainplan){
        String s1="update alstrainplan set GRADE="+alstrainplan.getGrade()+",OPTIONAL_CREDIT="+alstrainplan.getOptionalCredit()+",";
        String s2="LIMITE_CREDIT="+alstrainplan.getLimiteCredit()+",PROFESSIONAL_REQUIRED="+alstrainplan.getProfessionalRequired()+",";
        String s3="GENERAL_REQUIRED="+alstrainplan.getGeneralRequired()+",GENERAL_ELECTIVE="+alstrainplan.getGeneralElective()+",";
        String s4="DISCIPLINE_BASIS="+alstrainplan.getDisciplineBasis()+",PRACTICE_LINK="+alstrainplan.getPracticeLink();
        String s5=" where TRAINPLAN_ID="+alstrainplan.getTrainplanId();
        return s1+s2+s3+s4+s5;
    }


    /**
     * 修改培养方案的课程
     * @param
     * @return 返回查询sql
     */
    public static String updatePlainCourse(Alstrainplancourse alstrainplancourse){
        return " UPDATE alstrainplancourse SET COURSE_NAME='"+alstrainplancourse.getCourseName()+"',PLAN_COURSE_TERM="+alstrainplancourse.getPlanCourseTerm()+",CREDIT="+alstrainplancourse.getCredit()+",COURSE_TYPE='"+alstrainplancourse.getCourseType()+"',COURSE_HOURS='"+alstrainplancourse.getCourseHours()+"',COURSE_LEVEL="+alstrainplancourse.getCourseLevel()+"  WHERE TRAINPLANCOURSE_ID="+alstrainplancourse.getTrainplancourseId();
    }


    /**
     * 通过专业id和年级，获取培养方案的课程
     * @param
     * @return 返回查询sql
     */
    public static String selectePlainCourseByIdAndGrade( String majorID,String grade){
        return "select TRAINPLANCOURSE_ID,TRAINPLAN_ID,COURSE_NAME,PLAN_COURSE_TERM,CREDIT,COURSE_TYPE,COURSE_HOURS,COURSE_LEVEL from alstrainplancourse  where TRAINPLAN_ID=(select TRAINPLAN_ID from alstrainplan where MAJOR_ID="+majorID+" and GRADE="+grade+")";
    }

}
